$(function () {
    $('.su').addClass('current')
    var flage = true
    $('.sh').on('click', function () {
        if (flage) {
            $('.shu_l').height(130)
            $('.shai').removeClass('wo')
            $('.su').addClass('current')

            flage = false
        } else {
            $('.shu_l').height(32)
            $('.shai').addClass('wo')
            flage = true
        }
    })
    $('.shai ul:nth-child(1) a').on('click', function () {
        $(this).addClass('current').parent().siblings('li').find('a').removeClass('current')
    })
    $('.shai ul:nth-child(2) a').on('click', function () {
        $(this).addClass('current').parent().siblings('li').find('a').removeClass('current')
    })
    $('.shai ul:nth-child(3) a').on('click', function () {
        $(this).addClass('current').parent().siblings('li').find('a').removeClass('current')
    })
    $('.shai ul:nth-child(4) a').on('click', function () {
        $(this).addClass('current').parent().siblings('li').find('a').removeClass('current')
        $('.sh a').removeClass('current')
    })

    $(' .none li a').on('click', function () {
        $(this).addClass('current').parent().siblings('li').find('a').removeClass('current')
    })
    $(' .xuan li a').on('click', function () {
        $(this).addClass('current').parent().siblings('li').find('a').removeClass('current')
    })
    $(' .head li a').on('click', function () {
        $(this).addClass('current').parent().siblings('li').find('a').removeClass('current')
    })

    $('#cuy').on('click', function () {
        $('.foot').hide()
    })

    // 筛选功能
    var res = {
        data: [
            {
                id: 1,
                type: 1,
                id1: 1,
                typ1: 1,
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人1',
                tex: '你好1',
            },
            {
                id: 1,
                type: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人2',
                tex: '你好2',
            },
            {
                id: 1,
                type: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人3',
                tex: '你好3',
            },
            {
                id1: 1,
                typ1: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人11',
                tex: '你好11',
            },
            {
                id1: 1,
                type1: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人12',
                tex: '你好12',
            },
            {
                id2: 1,
                type2: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人111',
                tex: '你好111',
            },
            {
                id2: 1,
                type2: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人112',
                tex: '你好112',
            },
            {
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人113',
                tex: '你好113',
            },
            {
                id: 1,
                type: 1,
                id1: 1,
                typ1: 1,
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人1',
                tex: '你好1',
            },
            {
                id: 1,
                type: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人2',
                tex: '你好2',
            },
            {
                id: 1,
                type: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人3',
                tex: '你好3',
            },
            {
                id1: 1,
                typ1: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人11',
                tex: '你好11',
            },
            {
                id1: 1,
                type1: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人12',
                tex: '你好12',
            },
            {
                id2: 1,
                type2: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人111',
                tex: '你好111',
            },
            {
                id2: 1,
                type2: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人112',
                tex: '你好112',
            },
            {
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人113',
                tex: '你好113',
            },
            {
                id: 1,
                type: 1,
                id1: 1,
                typ1: 1,
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人1',
                tex: '你好1',
            },
            {
                id: 1,
                type: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人2',
                tex: '你好2',
            },
            {
                id: 1,
                type: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人3',
                tex: '你好3',
            },
            {
                id1: 1,
                typ1: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人11',
                tex: '你好11',
            },
            {
                id1: 1,
                type1: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人12',
                tex: '你好12',
            },
            {
                id2: 1,
                type2: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人111',
                tex: '你好111',
            },
            {
                id2: 1,
                type2: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人112',
                tex: '你好112',
            },
            {
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人113',
                tex: '你好113',
            },
            {
                id: 1,
                type: 1,
                id1: 1,
                typ1: 1,
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人1',
                tex: '你好1',
            },
            {
                id: 1,
                type: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人2',
                tex: '你好2',
            },
            {
                id: 1,
                type: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人3',
                tex: '你好3',
            },
            {
                id1: 1,
                typ1: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人11',
                tex: '你好11',
            },
            {
                id1: 1,
                type1: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人12',
                tex: '你好12',
            },
            {
                id2: 1,
                type2: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人111',
                tex: '你好111',
            },
            {
                id2: 1,
                type2: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人112',
                tex: '你好112',
            },
            {
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人113',
                tex: '你好113',
            },
            {
                id: 1,
                type: 1,
                id1: 1,
                typ1: 1,
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人1',
                tex: '你好1',
            },
            {
                id: 1,
                type: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人2',
                tex: '你好2',
            },
            {
                id: 1,
                type: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人3',
                tex: '你好3',
            },
            {
                id1: 1,
                typ1: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人11',
                tex: '你好11',
            },
            {
                id1: 1,
                type1: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人12',
                tex: '你好12',
            },
            {
                id2: 1,
                type2: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人111',
                tex: '你好111',
            },
            {
                id2: 1,
                type2: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人112',
                tex: '你好112',
            },
            {
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人113',
                tex: '你好113',
            },
            {
                id: 1,
                type: 1,
                id1: 1,
                typ1: 1,
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人1',
                tex: '你好1',
            },
            {
                id: 1,
                type: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人2',
                tex: '你好2',
            },
            {
                id: 1,
                type: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人3',
                tex: '你好3',
            },
            {
                id1: 1,
                typ1: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人11',
                tex: '你好11',
            },
            {
                id1: 1,
                type1: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人12',
                tex: '你好12',
            },
            {
                id2: 1,
                type2: 1,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人111',
                tex: '你好111',
            },
            {
                id2: 1,
                type2: 2,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人112',
                tex: '你好112',
            },
            {
                id2: 1,
                type2: 3,
                src: './images/8b843504867408d80c3a75fa2bb7132212379320.jpg@200w.jpg',
                text: '鬼灭之人113',
                tex: '你好113',
            },
        ],
    }

    var newData = []
    var obj = {}

    $('#shai_one li').on('click', function () {
        var index = $(this).index()

        if (index === 0) {
            newData = res.data.filter(function (value) {
                return value.id === 1
            })
        } else {
            newData = res.data.filter(function (value) {
                return value.id === 1 && value.type === index
            })
        }

        obj.newData = newData
        var xhl = template('tel', obj)
        $('.nei').html(xhl)
    })
    $('#shai_two li').on('click', function () {
        var index = $(this).index()
        if (index === 0) {
            newData = newData.filter(function (value) {
                return value.id1 === 1
            })
            console.log(newData)
        } else {
            newData = newData.filter(function (value) {
                return value.id1 === 1 && value.type1 === index
            })
        }
        if (index === 0) {
            newData = res.data.filter(function (value) {
                return value.id1 === 1
            })
        } else {
            newData = res.data.filter(function (value) {
                return value.id1 === 1 && value.type1 === index
            })
        }

        obj.newData = newData
        var xhl = template('tel', obj)
        $('.nei').html(xhl)
    })
    $('#shai_three li').on('click', function () {
        num2 = 1
        var index = $(this).index()

        if (index === 0) {
            newData = res.data.filter(function (value) {
                return value.id2 === 1
            })
        } else {
            newData = res.data.filter(function (value) {
                return value.id2 === 1 && value.type2 === index
            })
        }
        obj.newData = newData
        var xhl = template('tel', obj)
        $('.nei').html(xhl)
    })
})
